package com.ask.mapper;

import com.ask.entity.SetMeal;
import com.ask.entity.SetMealDish;
import com.ask.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetMealDishMapper {
    void insertBatch(List<SetMealDish> setMealDishes);

    @Select("select * from setmeal_dish where setmeal_id = #{setMealId}")
    List<SetMealDish>  getBySetMealId(Long setMealId);

    @Delete("delete from setmeal_dish where setmeal_id = #{setMealId}")
    void deleteBysetMealId(Long setMealId);

    @Select("       select d.description,d.image, sd.name, sd.copies\n" +
            "        from setmeal_dish sd\n" +
            "        left join dish d\n" +
            "        on sd.dish_id = d.id\n" +
            "        where sd.setmeal_id = #{setMealId}")
    List<DishItemVO> getDishesBySetMealId(Long setMealId);
}
